//
//  BubbleTransitionTestModalVC.swift
//  BubbleTransition
//
//  Created by elarc on 16/8/17.
//  Copyright © 2016年 elarc. All rights reserved.
//

import Foundation
import UIKit

 class BubbleTransitionTestModalVC: UIViewController {
   var closeButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        buildBtn()
    }
    
    func buildBtn() -> Void {
        closeButton = UIButton(type:.Custom)
        closeButton.frame = CGRectMake(0, 100, 100, 44)
        closeButton.setTitle("closeMe", forState: UIControlState.Normal)
        closeButton.backgroundColor = UIColor.blackColor()
        self.view.addSubview(closeButton)
        
        UIView.animateWithDuration(1) {
             self.closeButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
        }
        closeButton.addTarget(self, action: #selector(BubbleTransitionTestModalVC.closeAction(_:)), forControlEvents: UIControlEvents.TouchUpInside)
    }

    
    func closeAction(sender: AnyObject) {
        UIView.animateWithDuration(1) {
            self.closeButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
            self.dismissViewControllerAnimated(true, completion: nil)
        }
    }
    
}
